<form class="layui-form seller-form"  action="" >
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">订单号：</label>
            <div class="layui-input-inline ">
                <input type="text" name="order_id" required  class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label" style="width: 100px;">注册手机号：</label>
            <div class="layui-input-inline ">
                <input type="text" name="user_mobile" required  class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">是否结算：</label>
            <div class="layui-input-inline ">
                <select name="is_settlement">
                    <option value="0">请选择</option>
                    <option value="2">未结算</option>
                    <option value="1">已结算</option>
                    <option value="3">已作废</option>
                </select>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">创建时间：</label>
            <div class="layui-input-inline">
                <input type="text" name="cdate" id="cdate" placeholder="开始时间 到 结束时间" autocomplete="off"
                       class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">更新时间：</label>
            <div class="layui-input-inline">
                <input type="text" name="udate" id="udate" placeholder="开始时间 到 结束时间" autocomplete="off"
                       class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <button type="submit" class="layui-btn layui-btn-sm" lay-submit lay-filter="order-search"><i class="iconfont icon-chaxun"></i>筛选</button>
        </div>
    </div>
</form>
<div class="table-body">
    <table id="distributionOrderTable" lay-filter="order"></table>
</div>
<script>
    layui.use(['table','form','layer','laydate'],function() {
        var layer = layui.layer, table = layui.table, form = layui.form, laydate = layui.laydate;

        //时间插件
        laydate.render({
            elem: '#cdate',
            range: '到',
            format: 'yyyy-MM-dd'
        });
        //时间插件
        laydate.render({
            elem: '#udate',
            range: '到',
            format: 'yyyy-MM-dd'
        });

        //执行渲染
        table.render({
            elem: '#distributionOrderTable', //指定原始表格元素选择器（推荐id选择器）
            height: 'full-220',
            cellMinWidth: '80',
            page: 'true',
            limit: '20',
            id: 'distributionOrderTable',
            url: "{:get_addon_url('DistributionCenter://Index/order')}",
            cols: [[
                {type: 'numbers'},
                {field: 'user', title: '分销商姓名', align: 'center'},
                {field: 'buy_user', title: '购买用户', align: 'center'},
                {field: 'order_id', title: '订单号', width: 200, align: 'center'},
                {field: 'amount', title: '结算金额', align: 'center'},
                {field: 'is_settlement', sort: true, title: '是否结算', align: 'center',},
                {field: 'ctime', sort: true, title: '创建时间', align: 'center',},
                {field: 'utime', sort: true, title: '更新时间', align: 'center',},
                {fixed: 'right', title: '操作', toolbar: '#distributionTableBar'}
            ]]
        });
        form.on('submit(order-search)', function(data){
            layui.table.reload('distributionOrderTable', {
                where: data.field
                ,page: {
                    curr: 1
                }
            });
            return false;
        });

        //监听工具条
        table.on('tool(order)', function (obj) {
            var data = obj.data;
            var layEvent = obj.event;
            if (layEvent === 'cancle') {
                layer.confirm('真的要作废么', {icon: 3}, function (index) {
                    JsPost("{:get_addon_url('DistributionCenter://Index/cancleOrder')}", {id: data.id}, function (res) {
                        if (res.status) {
                            layui.table.reload('distributionOrderTable');
                            layer.close(index);
                        }
                        layer.msg(res.msg);
                    })
                });
            }
        });
    });
</script>

<script type="text/html" id="distributionTableBar">
    {{# if (d.is_settlement == '未结算') { }}
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="cancle">作废</a>
    {{# }; }}
</script>
